package  
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import ginger.events.DataEvent;
	import hwsoft.webservice_1_0.utils.ParseUtil;
	/**
	 * ...
	 * @author Ning
	 */
	public class Remote extends EventDispatcher
	{
		private var _urlloader:URLLoader;
		private var _p:int = 0;
		private var _hasNextPage:Boolean = true;
		public function Remote() 
		{
			//载入数据
			_urlloader = new URLLoader();
			_urlloader.addEventListener(Event.COMPLETE, onComplete);
		}
		/**
		 * 更新数据
		 */
		public function updateData():void
		{
			if (!_hasNextPage)
			    return;
			_p += 1;
			_urlloader.load(new URLRequest('http://hd.wissun.com/2012/idiom/indexflash.php?p=' + String(_p)));
		}
		private function onComplete(evt:Event):void
		{
			_hasNextPage = Boolean(XML(evt.target.data).ROWDATA.@['HASNEXTPAGE']);
			var data:Array = ParseUtil.parse(XML(evt.target.data), PhotoVO);
			dispatchEvent(new DataEvent(DataEvent.UPDATE, data));
		}
	}
}